<template>
  <div class="taolun">
    <el-dialog title="批示意见/办理提示" :visible.sync="noticeVisible" width="95%">
      <notice :noticePersonId="noticePersonId" :step="selStep"></notice>
      <div slot="footer" class="dialog-footer" style="overflow:hidden">
        <el-button @click.native="noticeVisible = false" style="float:right">关闭</el-button>
      </div>
    </el-dialog>
    <el-dialog
      title="录入领导批示"
      :visible.sync="dialogVisible"
      width="95%" :close-on-click-modal="false" :close-on-press-escape="false">
        <el-form
          ref="form"
          :model="shanghuiForm"
          label-width="150px"
          label-position="right"
          :rules="shanghuiFormRules">
          <el-form-item label="时间" prop="reportDate">
              <el-date-picker type="date" placeholder="选择时间" v-model="shanghuiForm.reportDate" value-format="yyyy-MM-dd"></el-date-picker>
          </el-form-item>
          <el-form-item label="上传附件">
              <el-upload
                class="upload-demo"
                :action="this.$http.defaults.baseURL+this.$http.defaults.selectionAPI +'api/gen/file/upload/'"
                :on-success="handleUploadSucc"
                :on-remove="handleRemove"
                :before-remove="beforeRemove"
                :on-error='uploadError'
                :multiple="true"
                :file-list="fileList">
                <el-button type="primary">点击上传</el-button>
              </el-upload>
          </el-form-item>
          <el-form-item label="部领导批示" prop="leaderOpinion">
            <leaderOpinion v-if="this.leaderMsg.persons" :recordId="this.leaderMsg.persons[0].busReportBatchId" recordTable="bus_report_batch" :leaderType="1" :canEdit="true"></leaderOpinion>
          </el-form-item>
          <el-form-item label="司领导批示" prop="leaderOpinion2">
            <leaderOpinion v-if="this.leaderMsg.persons" :recordId="this.leaderMsg.persons[0].busReportBatchId" recordTable="bus_report_batch" :leaderType="2" :canEdit="true"></leaderOpinion>
          </el-form-item>
          <el-form-item>
            <el-button type="success" class="marginT10" @click="leaderMsgClick" :loading="submitloading1">保存</el-button>
          </el-form-item>
        </el-form>
    </el-dialog>
    <el-dialog
      title="录入会议信息"
      :visible.sync="dialogVisible2"
      width="80%" :close-on-click-modal="false" :close-on-press-escape="false">
      <div class="wboxnoborder" style="width:100%">
        <el-table
          border
          :data="huiyiTable"
          tooltip-effect="dark"
          style="">
          <el-table-column
            label="序号"
            type="index"
            width="50">
          </el-table-column>
          <el-table-column
            prop="realName"
            label="姓名"
            width="150">
          </el-table-column>
          <el-table-column
            prop="unitName"
            width="250"
            label="选任岗位单位"
            show-overflow-tooltip>
          </el-table-column>
          <el-table-column
            prop="jobName"
            width="250"
            label="选任岗位职务"
            show-overflow-tooltip>
          </el-table-column>
          <el-table-column
            prop="jobLevel"
            label="选任岗位职级"
            width="150"
            show-overflow-tooltip>
          </el-table-column>
          <el-table-column label="审定情况">
            <template slot-scope="scope">
              <el-radio-group v-model="scope.row.radio" @change="entryHyMsgRadioChange">
                <el-radio :label="2">通过</el-radio>
                <el-radio :label="3">未通过</el-radio>
              </el-radio-group>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <el-form ref="huiyiForm" :model="huiyiForm" class="marginT15" label-width="120px" :rules="huiyiFormRules" :inline="true">
        <el-form-item label="第" label-width="110px" prop="meetingTimes">
          <el-input-number v-model="huiyiForm.meetingTimes" :min="1" style="margin:0 10px"></el-input-number> 次
        </el-form-item>
        <el-form-item label="" prop="meetingType">
          司办会
        </el-form-item>
        <el-form-item label="" prop="meetingDate">
            <el-date-picker
              v-model="huiyiForm.meetingDate"
              type="date" value-format="yyyy-MM-dd"
              placeholder="选择日期">
            </el-date-picker>
        </el-form-item>
        <div style="clear:both"></div><el-form-item label="第" label-width="110px" prop="meetingTimes2">
          <el-input-number v-model="huiyiForm.meetingTimes2" :min="1" style="margin:0 10px"></el-input-number> 次
        </el-form-item>
        <el-form-item label="" prop="meetingType">
          党组会
        </el-form-item>
        <el-form-item label="" prop="meetingDate2">
            <el-date-picker
              v-model="huiyiForm.meetingDate2"
              type="date" value-format="yyyy-MM-dd"
              placeholder="选择日期">
            </el-date-picker>
        </el-form-item>
        <div style="clear:both"></div>
        <el-form-item label="备注" prop="decisionContent">
            <el-input
              type="textarea"
              :rows="4"
              placeholder="请输入内容"
              v-model="huiyiForm.decisionContent"
              style="width:800px">
            </el-input>
        </el-form-item>
        <div style="clear:both"></div>
        <el-form-item label="上传会议纪要">
            <el-upload
              class="upload-demo"
              :action="this.$http.defaults.baseURL+this.$http.defaults.selectionAPI +'api/gen/file/upload/'"
              :on-success="handleUploadSucc2"
              :on-remove="handleRemove2"
              :before-remove="beforeRemove2"
              :on-error='uploadError2'
              :multiple="true"
              :file-list="fileList2">
              <el-button type="primary">点击上传</el-button>
            </el-upload>
        </el-form-item>
        <div style="clear:both"></div>
        <el-form-item>
          <el-button type="success" @click="finishTalking" :loading="submitloading2" style="margin-left:120px;">讨论决定完成，进入下一环节</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
    <el-breadcrumb separator=">">
      <el-breadcrumb-item :to="{ path: '/' }">系统首页</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/selection' }">干部选任</el-breadcrumb-item>
      <el-breadcrumb-item :to="{ path: '/selection/taolun' }">讨论决定</el-breadcrumb-item>
    </el-breadcrumb>
    <section class="wboxnoborder">
      <div :style="'height:'+tableHeight+'px'">
        <el-scrollbar style="height: calc(100% + 16px);">
          <el-tabs v-model="activeName" type="card" @tab-click="tabsClick" style="margin:15px">
            <el-tab-pane label="待提请审议" name="first">
              <span slot="label" v-if="countnum1>0" class="pointtab"><el-badge :value="countnum1" class="item">待提请审议</el-badge></span>
              <el-col :span="24">
                <el-table
                  v-loading="loading1"
                  border
                  :data="tableData"
                  tooltip-effect="dark"
                  style="width: 100%"
                  @selection-change="handleSelectionChange">
                  <el-table-column
                    type="selection"
                    width="55">
                  </el-table-column>
                  <el-table-column
                    label="序号"
                    type="index"
                    width="50">
                  </el-table-column>
                  <el-table-column
                    prop="realName"
                    label="姓名"
                    width="150">
                  </el-table-column>
                  <el-table-column
                    prop="candidateUnit"
                    label="目前单位">
                  </el-table-column>
                  <el-table-column
                    prop="currentJob"
                    label="目前职务"
                    width="250"
                    show-overflow-tooltip>
                  </el-table-column>
                  <el-table-column
                    prop="currentLevel"
                    label="目前职级"
                    width="150"
                    show-overflow-tooltip>
                  </el-table-column>
                  <el-table-column
                    prop="unitName"
                    label="选任岗位单位"
                    show-overflow-tooltip>
                  </el-table-column>
                  <el-table-column
                    prop="jobName"
                    width="250"
                    label="选任岗位职务"
                    show-overflow-tooltip>
                  </el-table-column>
                  <el-table-column
                    prop="jobLevel"
                    label="选任岗位职级"
                    width="150"
                    show-overflow-tooltip>
                  </el-table-column>
                  <el-table-column
                    label="办理提示、批示意见"
                    width="150">
                    <template slot-scope="scope">
                      <el-popover placement="bottom" width="600" trigger="hover">
                        <notice :noticePersonId="scope.row.id" :step="selStep"></notice>
                        <el-button size="small" slot="reference" type="primary" @click="showNotice(scope.row.id)">查看详情</el-button>
                      </el-popover>
                      <!-- <el-button @click="showNotice(scope.row.personId)" type="primary" size="small">查看详情</el-button> -->
                    </template>
                  </el-table-column>
                </el-table>
                <el-button class="marginT10" type="primary" @click="baobuClick" :loading="baobuloading">报部</el-button>
              </el-col>
            </el-tab-pane>
            <el-tab-pane label="签报与上会材料" name="second">
              <span slot="label" v-if="countnum2>0" class="pointtab"><el-badge :value="countnum2" class="item">签报与上会材料</el-badge></span>
              <el-table
                v-loading="loading2"
                border
                ref="multipleTable"
                :data="tableData2"
                tooltip-effect="dark"
                style="width: 100%">
                <el-table-column
                  label="序号"
                  type="index"
                  width="50">
                </el-table-column>
                <el-table-column
                  prop="persions"
                  label="人选">
                  <template slot-scope="scope">
                    <el-checkbox-group v-model="checkList">
                      <el-checkbox :label="item.personId" v-for="item of scope.row.persons" :key="item.personId" :disabled="item.onMeeting === 1">{{item.realName}}</el-checkbox>
                    </el-checkbox-group>
                  </template>
                </el-table-column>
                <el-table-column
                  label="操作">
                  <template slot-scope="scope">
                    <el-button type="primary" @click="exportqbmb(scope.row)">导出签报模板</el-button>
                    <el-button type="primary" class="marginL8" @click="enteringLeaderMsg(scope.row)">录入领导批示</el-button>
                    <el-button @click="delDsh(scope.row)" type="danger" class="marginL8">删除</el-button>
                  </template>
                </el-table-column>
              </el-table>
              <el-button class="marginT10" type="primary" :loading="shanghuiloading" @click="handleShanghuiClick">上会</el-button>
            </el-tab-pane>
            <el-tab-pane label="会议审议" name="third">
              <span slot="label" v-if="countnum3>0" class="pointtab"><el-badge :value="countnum3" class="item">会议审议</el-badge></span>
              <el-table
                v-loading="loading3"
                border
                ref="singleTable"
                :data="tableData3"
                style="width: 100%">
                <el-table-column
                  type="index"
                  width="50">
                </el-table-column>
                <el-table-column
                  prop="name"
                  label="人选">
                </el-table-column>
                <el-table-column label="操作">
                  <template slot-scope="scope">
                    <el-button
                      type="primary" @click="exportshmb(scope.row)">导出党组会材料模板</el-button>
                    <el-button
                      type="primary"
                      @click="entryHyMsg(scope.row)">录入会议信息</el-button>
                    <el-button
                      type="danger"
                      @click="delHysy(scope.row)">删除</el-button>
                  </template>
                </el-table-column>
              </el-table>
            </el-tab-pane>
          </el-tabs>
        </el-scrollbar>
      </div>
    </section>
  </div>
</template>

<script>
import selectGroup from '../common/SelectGroup2'
import notice from '../common/Notice'
import taolundetail from './Detail'
import leaderOpinion from '../common/leaderOpinion'
export default {
  name: 'taolun',
  components: {
    selectGroup,
    notice,
    taolundetail,
    leaderOpinion
  },
  data () {
    return {
      countnum1: 0,
      countnum2: 0,
      countnum3: 0,
      loading1: false,
      loading2: false,
      loading3: false,
      submitloading1: false,
      submitloading2: false,
      baobuloading: false,
      shanghuiloading: false,
      tableHeight: 100,
      activeName: 'first',
      tableData: [],
      tableData2: [],
      tableData3: [],
      huiyiTable: [],
      baobuData: [], // 报部
      checkList: [], // 上会签报
      checkList2: [],
      leaderMsg: {}, // 上会签报 录入领导批示 item
      shanghuiForm: { // 上会签报 领导批示
        reportDate: '',
        leaderOpinion: '',
        leaderOpinion2: '',
        leaderOpinion3: ''
      },
      shanghuiFormRules: {
        reportDate: [{ required: true, message: '报部日期不能为空', trigger: 'blur' }]
      },
      huiyiFormRules: {
        meetingTimes: [{ required: true, message: '请选择第几次会议', trigger: 'blur' }],
        meetingDate: [{ required: true, message: '会议日期不能为空', trigger: 'blur' }]
      },
      files: [],
      fileList: [], // 上会签报 录入领导批示 附件上传
      huiyiForm: { // 会议审议 录入会议信息
        selOptions: [
          {
            value: '1',
            label: '党组会'
          },
          {
            value: '2',
            label: '司办会'
          }
        ],
        meetingTimes: 1,
        meetingType: '',
        meetingDate: '',
        decisionContent: '',
        radio: ''
      },
      decisionMeetingId: '', // 会议审议 批次id
      decisionMeetingPersons: [], // 会议审议 批次人员信息
      files2: [],
      fileList2: [],
      date: '',
      selectPerson: [], // 公示完成 待报出
      selectPerson2: [], // 已退回
      selApi: 'api/selection/decision/submitApprove',
      selStep: 5,
      noticePersonId: '', // notice persion id
      noticeVisible: false,
      dialogVisible: false, // 录入领导批示
      dialogVisible2: false, // 录入会议信息
      dialogVisible3: false, // 退回批示
      detailMsg: {}, // 报部信息 会议信息存储
      msgArr: ['无', '党组会', '司办会'],
      personId: ''
    }
  },
  methods: {
    exportqbmb (data) {
      let id = data.persons[0].busReportBatchId
      let url = this.$http.defaults.selectionAPI + 'api/selection/document/exportTljdQbmb?batchId=' + id
      // console.log(url)
      this.$http.get(url).then(res => {
        if (res.data.success === true) {
          this.download(res.data.result)
        } else {
          this.$message({
            message: '人选民主推荐、考察环节信息不完整，无法导出',
            type: 'error'
          })
        }
      })
      // window.open(this.$http.defaults.baseURL + this.$http.defaults.selectionAPI + 'api/selection/document/exportDhjlb?batchId=' + id)
    },
    exportshmb (data) {
      let id = data.id
      let url = this.$http.defaults.selectionAPI + 'api/selection/document/exportDzhclmb?batchId=' + id
      // console.log(url)
      this.$http.get(url).then(res => {
        if (res.data.success === true) {
          this.download(res.data.result)
        } else {
          this.$message({
            message: '人选民主推荐、考察环节信息不完整，无法导出',
            type: 'error'
          })
        }
      })
      // window.open(this.$http.defaults.baseURL + this.$http.defaults.selectionAPI + 'api/selection/document/exportDhjlb?batchId=' + id)
    },
    download (fileid) {
      var downloadElement = document.createElement('a')
      downloadElement.href = this.$http.defaults.baseURL + this.$http.defaults.selectionAPI + 'api/gen/file/download?id=' + fileid
      document.body.appendChild(downloadElement)
      downloadElement.click() // 点击下载
      document.body.removeChild(downloadElement) // 下载完成移除元素
    },
    showNotice (id) {
      console.log('show notice id:', id)
      this.noticePersonId = id
      this.noticeVisible = true
    },
    getNum () {
      let url = this.$http.defaults.selectionAPI + 'api/selection/statnum/decision/getStatNum'
      // console.log(url)
      this.$http.get(url).then(res => {
        if (res.data.success === true) {
          this.countnum1 = res.data.result.countnum5 // 处内人员的countnum1对应处长的countnum5
          this.countnum2 = res.data.result.countnum2
          this.countnum3 = res.data.result.countnum3
        } else {
          this.$message({
            message: '数据获取失败',
            type: 'error'
          })
        }
      })
    },
    tabsClick (tab) { // tab切换
      console.log('tab change:', tab.name)
      let tn = tab.name
      if (tn === 'first') {
        this.getList()
      } else if (tn === 'second') {
        this.getList2()
      } else if (tn === 'third') {
        this.getList3()
      }
    },
    // getList () { // 待提请审议
    //   this.loading1 = true
    //   let url = this.$http.defaults.selectionAPI + 'api/selection/decision/getNotProcessedPersons?sended=0'
    //   // console.log(url)
    //   this.$http.get(url, {}).then(res => {
    //     this.loading1 = false
    //     console.log('get list succ:', res)
    //     if (res.data.success === true) {
    //       let rs = res.data.result
    //       this.tableData = rs
    //     } else {
    //       this.$message({
    //         message: '数据获取失败',
    //         type: 'error'
    //       })
    //     }
    //   })
    // },
    getList2 () { // 上会签报
      this.getNum()
      this.loading2 = true
      let url = this.$http.defaults.selectionAPI + 'api/selection/decision/getNotProcessedReportBatch'
      // console.log(url)
      this.$http.get(url, {}).then(res => {
        this.loading2 = false
        console.log('get list2 succ:', res)
        if (res.data.success === true) {
          let rs = res.data.result.reportBatch
          this.tableData2 = rs
        } else {
          this.$message({
            message: '数据获取失败',
            type: 'error'
          })
        }
      })
    },
    getList3 () { // 会议审议
      this.getNum()
      this.loading3 = true
      let url = this.$http.defaults.selectionAPI + 'api/selection/decision/getNotProcessedMeetingBatch'
      // console.log(url)
      this.$http.get(url, {}).then(res => {
        this.loading3 = false
        console.log('get list3 succ:', res)
        if (res.data.success) {
          let rs = res.data.result.decisionMeeting
          let arr = []
          if (rs) {
            for (let i of rs) {
              let brr = []
              for (let j of i.persons) {
                brr.push(j.realName)
              }
              arr.push({
                id: i.persons[0].decisionMeetingId,
                name: brr.join(' '),
                persons: i.persons
              })
            }
          }
          console.log('会议审议批次数据arr:', arr)
          this.tableData3 = arr
        } else {
          this.$message({
            message: '数据获取失败',
            type: 'error'
          })
        }
      })
    },
    getList () { // 已退回
      this.getNum()
      this.loading1 = true
      let url = this.$http.defaults.selectionAPI + 'api/selection/approve/getUserApproveList'
      // console.log(url)
      this.$http.post(url, {step: 5}).then(res => {
        this.loading1 = false
        console.log('get list5 succ:', res)
        if (res.data.success === true) {
          let rs = res.data.result
          let arr = []
          for (let i of rs) {
            arr.push({
              id: i.busCandidatePersonId,
              jobLevel: i.jobLevel,
              jobName: i.jobName,
              realName: i.realName,
              unitName: i.unitName,
              checkmsg: [i.statePublicity === -1 ? '' : '1', i.stateRecord === -1 ? '' : '2']
            })
          }
          console.log('get list5arr:', arr)
          this.tableData = arr
        } else {
          this.$message({
            message: '数据获取失败',
            type: 'error'
          })
        }
      })
    },
    handleSelectionChange (val) { // 待提请审议
      console.log('tabledata val:', val)
      this.baobuData = val
    },
    baobuClick () { // 报部
      if (this.baobuData && this.baobuData.length > 0) {
        console.log('click baobu')
        this.baobuloading = true
        let arr = []
        for (let i of this.baobuData) {
          let personId = ''
          if (i.personId) {
            personId = i.personId
          } else {
            personId = i.id
          }
          arr.push(personId)
        }
        let url = this.$http.defaults.selectionAPI + 'api/selection/decision/saveReportBatch'
        this.$http.post(url, {
          personIds: arr
        }).then(res => {
          console.log('报部succ res:', res)
          this.baobuloading = false
          if (res.data.success === true) {
            this.$message({
              message: '报部成功',
              type: 'success'
            })
            this.getList()
          } else {
            this.$message({
              message: res.data.message,
              type: 'error'
            })
          }
        })
      } else {
        this.$message({
          message: '请至少选择一个人选',
          type: 'error'
        })
      }
    },
    enteringLeaderMsg (item) { // 录入领导批示
      console.log('录入领导批示:', item)
      this.dialogVisible = true
      this.leaderMsg = item
      this.fileList = []
      this.files = []
      let url = this.$http.defaults.selectionAPI + 'api/selection/decision/getBatchFiles?reportBatchId=' + item.persons[0].busReportBatchId
      this.$http.get(url).then(res => {
        if (res.data.success === true) {
          this.shanghuiForm = res.data.result
          console.log('fileList网络获取')
          for (let item of res.data.result.files) {
            console.log({id: item.id, url: item.relativePath, name: item.fileName + '.' + item.fileType})
            this.fileList.push({id: item.id, url: item.relativePath, name: item.fileName + '.' + item.fileType})
            this.files.push(item.id)
          }
        }
      })
    },
    leaderMsgClick () { // 录入领导批示 表单提交
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.submitloading1 = true
          console.log('submit leader msg form')
          let id = this.leaderMsg.persons[0].busReportBatchId
          let url = this.$http.defaults.selectionAPI + 'api/selection/decision/saveReportBatchOpinion'
          // let arr = []
          // for (let i of this.files) {
          //   arr.push(i.id)
          // }
          // console.log('录入领导批示 上传附件arr:', arr)
          this.$http.post(url, {
            reportBatchId: id,
            reportDate: this.shanghuiForm.reportDate,
            leaderOpinion: this.shanghuiForm.leaderOpinion,
            leaderOpinion2: this.shanghuiForm.leaderOpinion2,
            leaderOpinion3: this.shanghuiForm.leaderOpinion3,
            files: this.files
          }).then(res => {
            this.submitloading1 = false
            console.log('录入领导批示submit:', res)
            if (res.data.success === true) {
              this.$message({
                message: '录入成功',
                type: 'success'
              })
              this.dialogVisible = false
            }
          })
        }
      })
    },
    delDsh (item) { // 删除上会签报批次
      console.log('删除上会签报批次:', item)
      this.$confirm('是否删除签报与上会材料批次', '操作确认', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let url = this.$http.defaults.selectionAPI + 'api/selection/decision/removeReportBatch'
        let id = item.persons[0].busReportBatchId
        this.$http.get(url, {
          params: {
            reportBatchId: id
          }
        }).then(res => {
          console.log('删除上会签报批次res:', res)
          if (res.data.success === true) {
            this.$message({
              message: '删除成功',
              type: 'success'
            })
            this.getList2()
          } else {
            this.$message({
              message: res.data.message,
              type: 'error'
            })
          }
        })
      }).catch(() => {
        console.log('取消删除')
      })
    },
    handleUploadSucc (response, file, fileList) { // 带上会审议 录入领导批示 附件
      console.log(response)
      if (response.success) {
        this.files.push(response.result[0].id)
        for (let item of response.result) {
          this.fileList.push({name: item.fileName + '.' + item.fileType, url: item.relativePath, id: item.id})
        }
        this.$message({
          message: '上传成功！' + response.message,
          type: 'success'
        })
      } else {
        this.$message({
          message: '上传失败:' + response.message,
          type: 'error'
        })
      }
    },
    beforeRemove (file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`)
    },
    handleRemove (file, fileList) {
      console.log(file)
      console.log('file.id')
      console.log(file.id)
      let fid = file.id
      let url = this.$http.defaults.selectionAPI + 'api/gen/file/remove'
      this.$http.get(url, {
        params: {
          id: fid
        }
      }).then(res => {
        console.log('删除成功:', res)
        if (res.data.success === true) {
          let index = this.files.indexOf(fid)
          if (index !== -1) {
            this.files.splice(index, 1)
            this.$message({
              message: '删除成功！',
              type: 'success'
            })
          }
        }
      })
    },
    uploadError (err) {
      console.log(err)
      this.$message({
        message: '上传失败:' + err,
        type: 'error'
      })
    },
    handleShanghuiClick () { // 上会签报 上会
      console.log('click shanghui', this.checkList)
      if (this.checkList.length === 0) {
        this.$message({
          message: '至少选择一人上会',
          type: 'warning'
        })
        return
      }
      this.shanghuiloading = true
      let url = this.$http.defaults.selectionAPI + 'api/selection/decision/savePersonsToMeetingBatch'
      this.$http.post(url, {
        personIds: this.checkList
      }).then(res => {
        this.shanghuiloading = false
        console.log('批量提交上会res:', res)
        if (res.data.success === true) {
          this.$message({
            message: '上会成功',
            type: 'success'
          })
          this.checkList = []
          this.getList2()
        } else {
          this.$message({
            message: '操作失败：' + res.data.message,
            type: 'error'
          })
        }
      })
    },
    entryHyMsg (item) { // 会议审议 点击 录入会议信息 按钮
      console.log('录入信息item:', item)
      this.dialogVisible2 = true
      this.decisionMeetingId = item.id
      this.huiyiTable = item.persons
      this.decisionMeetingPersons = item.persons
      // 重置会议信息表单
      this.huiyiForm.meetingTimes = 1
      this.huiyiForm.meetingType = ''
      this.huiyiForm.meetingDate = ''
      this.huiyiForm.decisionContent = ''
      this.huiyiForm.radio = ''
      this.files2 = []
      this.fileList2 = []
    },
    entryHyMsgRadioChange (item) { // 会议审议 录入会议信息 radio
      console.log('通过未通过状态改变item', item)
      if (item === 3) {
        this.$message({
          message: '此操作将终止改人选选任工作',
          type: 'warning'
        })
      }
    },
    delHysy (item) { // 会议审议删除
      console.log('会议审议删除item:', item)
      this.$confirm('是否删除会议审议批次', '操作确认', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        let url = this.$http.defaults.selectionAPI + 'api/selection/decision/removeMeetingBatch'
        this.$http.get(url, {
          params: {
            decisionMeetingId: item.id
          }
        }).then(res => {
          console.log('会议审议删除res:', res)
          if (res.data.success === true) {
            this.$message({
              message: '删除成功',
              type: 'success'
            })
            this.getList3()
          } else {
            this.$message({
              message: res.data.message,
              type: 'error'
            })
          }
        })
      }).catch(() => {
        console.log('取消删除')
      })
    },
    handleUploadSucc2 (response, file, fileList) { // 会议审议 录入会议信息 附件
      console.log(response)
      if (response.success) {
        this.files2.push(response.result[0].id)
        for (let item of response.result) {
          this.fileList2.push({name: item.fileName + '.' + item.fileType, url: item.relativePath, id: item.id})
        }
        this.$message({
          message: '上传成功！' + response.message,
          type: 'success'
        })
      } else {
        this.$message({
          message: '上传失败:' + response.message,
          type: 'error'
        })
      }
    },
    beforeRemove2 (file, fileList) {
      return this.$confirm(`确定移除 ${file.name}？`)
    },
    handleRemove2 (file, fileList) {
      console.log(file, fileList)
      let fid = file.response.result[0].id
      let url = this.$http.defaults.selectionAPI + 'api/gen/file/remove'
      this.$http.get(url, {
        params: {
          id: fid
        }
      }).then(res => {
        console.log('删除成功:', res)
        if (res.data.success === true) {
          let index = this.files2.indexOf(fid)
          if (index !== -1) {
            this.files2.splice(index, 1)
            this.$message({
              message: '删除成功！',
              type: 'success'
            })
          }
        }
      })
    },
    uploadError2 (err) {
      console.log(err)
      this.$message({
        message: '上传失败:' + err,
        type: 'error'
      })
    },
    finishTalking () { // 公示已备案，进入下一环节
      this.$refs['huiyiForm'].validate((valid) => {
        if (valid) {
          console.log(this.decisionMeetingPersons)
          let brr = []
          for (let i of this.decisionMeetingPersons) {
            if (i.radio) {
              brr.push({
                personId: i.personId,
                stateDecisionMeeting: i.radio
              })
            } else {
              this.$message({
                message: '全部人员的审定情况都需要选择！',
                type: 'warning'
              })
              return
            }
          }
          // console.log('return test', brr)
          let url = this.$http.defaults.selectionAPI + 'api/selection/decision/updateDecisionMeeting'
          // let arr = []
          // for (let i of this.files2) {
          //   arr.push(i.id)
          // }
          this.submitloading2 = true
          this.$http.post(url, {
            decisionMeetingId: this.decisionMeetingId,
            meetingTimes: this.huiyiForm.meetingTimes,
            meetingDate: this.huiyiForm.meetingDate,
            decisionContent: this.huiyiForm.decisionContent,
            meetingTimes2: this.huiyiForm.meetingTimes2,
            meetingDate2: this.huiyiForm.meetingDate2,
            meetingType: 2,
            files: this.files2,
            persons: brr
          }).then(res => {
            this.submitloading2 = false
            console.log('录入会议信息res:', res)
            if (res.data.success === true) {
              this.$message({
                message: '提交成功',
                type: 'success'
              })
              this.getList3()
              this.dialogVisible2 = false
            } else {
              this.$message({
                message: '保存失败：' + res.data.message,
                type: 'error'
              })
            }
          })
        }
      })
    },
    tableresize (obj) {
      var clientHeight = 0
      if (document.body.clientHeight && document.documentElement.clientHeight) {
        clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      } else {
        clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
      }
      obj.$nextTick(function () {
        obj.tableHeight = clientHeight - 165
      })
    }
  },
  mounted () {
    console.log('讨论决定')
    this.getList()
    this.tableresize(this)
    let _this = this
    window.onresize = function windowResize () {
      // 通过捕获系统的onresize事件触发我们需要执行的事件
      _this.tableresize(_this)
    }
  }
}
</script>
<style>
.taolun .el-table--border td, .el-table--border th, .el-table__body-wrapper .el-table--border.is-scrolling-left~.el-table__fixed{
  border-bottom:1px solid #95B8E7;
}
.taolun .el-table td, .el-table th.is-leaf{
  border-right:1px solid #95B8E7;
}
.taolun .wboxnoborder .el-table{
  border: #95B8E7 solid 1px;
}
.taolun .wboxnoborder .el-table th{
  font-weight: normal;
  background-image: linear-gradient(to bottom , #f8f8f8, #efefef);
  text-align: center;
  border-right: #95B8E7 solid 1px;
  border-bottom: #95B8E7 solid 1px;
  min-height: 30px;
  line-height:30px;
}
.taolun .wboxnoborder .el-table td, .el-table th{
  padding:0;
  font-size:var(--size14) !important;
  line-height: 20px;
  font-family: '宋体';
  text-align: center;
}
.taolun .el-table__row{
  height: 50px;
}
</style>
<style scoped>
.taolun {
  width: 100%;
}
.detail-tit {
  width: 100%;
  height: 50px;
  line-height: 50px;
  padding: 0 8px;
  box-sizing: border-box;
  font-size: 15px;
  font-weight: bolder;
}
.detail-item {
  width: 100%;
  height: 40px;
  padding: 0 8px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  border-bottom: 0.5px solid #ccc;
}
.detail-item-left {
  width: 20%;
  font-size: 14px;
}
.detail-item-right {
  width: 80%;
  font-size: 14px;
}
.taolun .wboxnoborder {
  padding: 0;
  width: 100%;
  background-color: #fff;
  margin: 0 10px;
  overflow: hidden;
}
</style>
